﻿using Rectangles;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

  
/// <summary>
///This is a test class for RectangleTest and is intended
///to contain all RectangleTest Unit Tests
///</summary>
[TestClass()]
public class RectangleTest
{


    private TestContext testContextInstance;

    /// <summary>
    ///Gets or sets the test context which provides
    ///information about and functionality for the current test run.
    ///</summary>
    public TestContext TestContext
    {
        get
        {
            return testContextInstance;
        }
        set
        {
            testContextInstance = value;
        }
    }

    #region Additional test attributes
    // 
    //You can use the following additional attributes as you write your tests:
    //
    //Use ClassInitialize to run code before running the first test in the class
    //[ClassInitialize()]
    //public static void MyClassInitialize(TestContext testContext)
    //{
    //}
    //
    //Use ClassCleanup to run code after all tests in a class have run
    //[ClassCleanup()]
    //public static void MyClassCleanup()
    //{
    //}
    //
    //Use TestInitialize to run code before running each test
    //[TestInitialize()]
    //public void MyTestInitialize()
    //{
    //}
    //
    //Use TestCleanup to run code after each test has run
    //[TestCleanup()]
    //public void MyTestCleanup()
    //{
    //}
    //
    #endregion


    /// <summary>
    ///A test for Rectangle Constructor
    ///</summary>
    [TestMethod()]
    public void RectangleConstructorTest()
    {
        int positionX = 1; 
        int positionY = 2; 
        int width = 2; 
        int hight = 2; 
        Rectangle target = new Rectangle(positionX, positionY, width, hight);
        Assert.AreEqual(target.PositionX,positionX);
        Assert.AreEqual(target.PositionY, positionY);
        Assert.AreEqual(target.Width,width);
        Assert.AreEqual(target.Hight,hight);
    }

    /// <summary>
    ///A test for CalculateArea
    ///</summary>
    [TestMethod()]
    public void CalculateAreaTest()
    {
        int positionX = 1;
        int positionY = 1;
        int width = 2; 
        int hight = 2; 
        Rectangle target = new Rectangle(positionX, positionY, width, hight);
        int expected = 4;
        int actual;
        actual = target.CalculateArea();
        Assert.AreEqual(expected, actual);
    }

    /// <summary>
    ///A test for Clone
    ///</summary>
    [TestMethod()]
    public void CloneTest()
    {
        int positionX = 2;
        int positionY = 2; 
        int width = 4; 
        int hight = 4; 
        Rectangle target = new Rectangle(positionX, positionY, width, hight);
        Rectangle cloned = (Rectangle)target.Clone();
        Assert.AreEqual(target.PositionX, cloned.PositionX);
        Assert.AreEqual(target.PositionY, cloned.PositionY);
        Assert.AreEqual(target.Width, cloned.Width);
        Assert.AreEqual(target.Hight, cloned.Hight);
    }

    [TestMethod()]
    public void IsCloneDeepTest()
    {
        int positionX = 2;
        int positionY = 2;
        int width = 4;
        int hight = 4;
        Rectangle target = new Rectangle(positionX, positionY, width, hight);
        Rectangle cloned = (Rectangle)target.Clone();
        target.PositionX = 1;
        Assert.AreNotEqual(target.PositionX, cloned.PositionX);
    }

    /// <summary>
    ///A test for CompareTo
    ///</summary>
    [TestMethod()]
    public void CompareToEquelTest()
    {
        int positionX = 2; 
        int positionY = 2;
        int width = 2; 
        int hight = 2; 
        Rectangle target = new Rectangle(positionX, positionY, width, hight);
        Rectangle other = new Rectangle(positionX, positionY, width, hight);
        Assert.AreEqual(target.CompareTo(other),0);

    }

    [TestMethod()]
    public void CompareToNotEquelTest()
    {
        int positionX = 2;
        int positionY = 2;
        int width = 2;
        int hight = 2;
        Rectangle target = new Rectangle(positionX, positionY, width, hight);
        Rectangle other = new Rectangle(positionX, positionY, width+2, hight);
        Assert.AreNotEqual(target.CompareTo(other), 0);

    }


  
}